package com.fh.shop.api.config;

import com.fh.shop.api.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <beans></beans>
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * <mvc:interceptors>
     *     <mvc:interceptor>
     * @param registry
     */
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns();
    }

    /**
     * <bean id="loginInterceptor" class="com.fh.shop.api.interceptor.LoginInterceptor"/>
     * @return
     */
    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }
}
